using Business.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;

namespace Business.Permissions
{
    public class BusinessPermissionDefinitionProvider: PermissionDefinitionProvider
    {

        public override void Define(IPermissionDefinitionContext context)
        {
            var Business = context.AddGroup(BusinessPermissions.Business, L("Business"), MultiTenancySides.Tenant);

            var Book = Business.AddPermission(BusinessPermissions.Book.Default, L("Book"));
            Book.AddChild(BusinessPermissions.Book.Update, L("Edit"));
            Book.AddChild(BusinessPermissions.Book.Delete, L("Delete"));
            Book.AddChild(BusinessPermissions.Book.Create, L("Create"));

            var PrintTemplate = Business.AddPermission(BusinessPermissions.PrintTemplate.Default, L("PrintTemplate"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Update, L("Edit"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Delete, L("Delete"));
            PrintTemplate.AddChild(BusinessPermissions.PrintTemplate.Create, L("Create"));

            var Procurement = Business.AddPermission(BusinessPermissions.Procurement.Default, L("Procurement"));
            Procurement.AddChild(BusinessPermissions.Procurement.Update, L("Edit"));
            Procurement.AddChild(BusinessPermissions.Procurement.Delete, L("Delete"));
            Procurement.AddChild(BusinessPermissions.Procurement.Create, L("Create"));

            var Formmian = Business.AddPermission(BusinessPermissions.Formmian.Default, L("Formmian"));
            Formmian.AddChild(BusinessPermissions.Formmian.Update, L("Edit"));
            Formmian.AddChild(BusinessPermissions.Formmian.Delete, L("Delete"));
            Formmian.AddChild(BusinessPermissions.Formmian.Create, L("Create"));

            var Good = Business.AddPermission(BusinessPermissions.Good.Default, L("Good"));
            Good.AddChild(BusinessPermissions.Good.Update, L("Edit"));
            Good.AddChild(BusinessPermissions.Good.Delete, L("Delete"));
            Good.AddChild(BusinessPermissions.Good.Create, L("Create"));

            var Purchase = Business.AddPermission(BusinessPermissions.Purchase.Default, L("Purchase"));
            Purchase.AddChild(BusinessPermissions.Purchase.Update, L("Edit"));
            Purchase.AddChild(BusinessPermissions.Purchase.Delete, L("Delete"));
            Purchase.AddChild(BusinessPermissions.Purchase.Create, L("Create"));

            var InventoryQuantity = Business.AddPermission(BusinessPermissions.InventoryQuantity.Default, L("InventoryQuantity"));
            InventoryQuantity.AddChild(BusinessPermissions.InventoryQuantity.Update, L("Edit"));
            InventoryQuantity.AddChild(BusinessPermissions.InventoryQuantity.Delete, L("Delete"));
            InventoryQuantity.AddChild(BusinessPermissions.InventoryQuantity.Create, L("Create"));


            var SpecType = Business.AddPermission(BusinessPermissions.SpecType.Default, L("SpecType"));
            SpecType.AddChild(BusinessPermissions.SpecType.Update, L("Edit"));
            SpecType.AddChild(BusinessPermissions.SpecType.Delete, L("Delete"));
            SpecType.AddChild(BusinessPermissions.SpecType.Create, L("Create"));

            var Spec = Business.AddPermission(BusinessPermissions.Spec.Default, L("Spec"));
            Spec.AddChild(BusinessPermissions.Spec.Update, L("Edit"));
            Spec.AddChild(BusinessPermissions.Spec.Delete, L("Delete"));
            Spec.AddChild(BusinessPermissions.Spec.Create, L("Create"));


            var Brand = Business.AddPermission(BusinessPermissions.Brand.Default, L("Brand"));
            Brand.AddChild(BusinessPermissions.Brand.Update, L("Edit"));
            Brand.AddChild(BusinessPermissions.Brand.Delete, L("Delete"));
            Brand.AddChild(BusinessPermissions.Brand.Create, L("Create"));


            var  InboundAppointments = Business.AddPermission(BusinessPermissions. InboundAppointments.Default, L(" InboundAppointments"));
             InboundAppointments.AddChild(BusinessPermissions. InboundAppointments.Update, L("Edit"));
             InboundAppointments.AddChild(BusinessPermissions. InboundAppointments.Delete, L("Delete"));
             InboundAppointments.AddChild(BusinessPermissions. InboundAppointments.Create, L("Create"));

            //Code generation...
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<BusinessResource>(name);
        }
    }
}
